package com.cskaoyan.shopping.dto;

import com.cskaoyan.mall.commons.constant.SysRetCodeConstants;
import com.cskaoyan.mall.commons.exception.ValidateException;
import com.cskaoyan.mall.commons.result.AbstractRequest;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;


@Data
public class AddCartRequest extends AbstractRequest {


    private Long userId;
    @JsonProperty("productId")
    private Long itemId;
    @JsonProperty("productNum")
    private Integer num;

    @Override
    public void requestCheck() {
        if (userId == null || userId < 0 || itemId == null || itemId < 0 || num == null || num < 0) {
            throw new ValidateException(SysRetCodeConstants.REQUEST_FORMAT_ILLEGAL.getCode(),
                    SysRetCodeConstants.REQUEST_FORMAT_ILLEGAL.getMessage());
        }
    }
}
